//
//  MySceneModel.m
//  BrushFace
//
//  Created by timer_q on 15/12/25.
//  Copyright © 2015年 Zzz. All rights reserved.
//


#import "MySceneModel.h"
#import "NavStatus.h"
#import "AlertDialogHelper.h"
@implementation MySceneModel
- (void)loadSceneModel{
    [super loadSceneModel];
}

//个人信息
- (void)user_getMyIndexForAppAndCB:(void(^)(id output))CB{
    NSString *requestStr = [NSString stringWithFormat:@"%@/user/getmyindexforapp.json",SERVICE_ADRESS];
    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    manager.responseSerializer  = [[AFHTTPResponseSerializer alloc] init];
    [manager GET:requestStr parameters:nil success:^(AFHTTPRequestOperation * _Nonnull operation, id  _Nonnull responseObject) {
        NSDictionary *jsonDict = [NSJSONSerialization JSONObjectWithData:responseObject options:0 error:nil];
        CB(jsonDict);
    } failure:^(AFHTTPRequestOperation * _Nullable operation, NSError * _Nonnull error) {
        
    }];


}

//实名认证
- (void)user_toFullNamedWithName:(NSString *)name andId:(NSString *)userId and:(void (^)(BOOL isSuccess))CB{
    name = [self replayRequestStr:name];
    NSDictionary *params = @{@"name":name,
                             @"code":userId
                             };
    NSString *requestStr = [NSString stringWithFormat:@"%@/user/tofullnamed.json",SERVICE_ADRESS];
    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    manager.responseSerializer = [[AFHTTPResponseSerializer alloc] init];
    [manager GET:requestStr parameters:params success:^(AFHTTPRequestOperation * _Nonnull operation, id  _Nonnull responseObject) {
        NSDictionary *jsonObject = [NSJSONSerialization JSONObjectWithData:responseObject options:0 error:nil];
        if (jsonObject) {
            if ([[jsonObject objectForKey:@"rtype"] integerValue]==0) {
                CB(YES);
            }else{
                [AlertDialogHelper showToast:[jsonObject objectForKey:@"errormsg"]];

                CB(NO);
            }
        }
    } failure:^(AFHTTPRequestOperation * _Nullable operation, NSError * _Nonnull error) {
        ITLogSP(@"error:%@",error.description);
    }];
}

//我的借入
- (void)user_listMyReplanWithCurPage:(int)curPage andRPP:(int)rpp andType:(NSString *)type andCB:(void (^)(NSDictionary *rqOutput))CB;{
    NSDictionary *params = @{@"curPage":[NSString stringWithFormat:@"%d",curPage],
                             @"rPP":[NSString stringWithFormat:@"%d",rpp],
                             @"status":type
                             };
    NSString *requestStr = [NSString stringWithFormat:@"%@/hope/selectmyhopeforapp.json",SERVICE_ADRESS];
    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    manager.responseSerializer = [[AFHTTPResponseSerializer alloc] init];
    [manager GET:requestStr parameters:params success:^(AFHTTPRequestOperation * _Nonnull operation, id  _Nonnull responseObject) {
        NSDictionary *jsonObject = [NSJSONSerialization JSONObjectWithData:responseObject options:0 error:nil];
        /*
         status 1借款中 2满标   4还款中   5逾期   7流标    8已还款
         hopeamount 总金额
         days 期限
         priod 期限 不为0显示这个  为了显示days
         hoperate 利息
         investamount 已借金额
         id  借款id
         */
        CB(jsonObject);
        ITLogSP(@"%@",jsonObject);
    } failure:^(AFHTTPRequestOperation * _Nullable operation, NSError * _Nonnull error) {
        ITLogSP(@"error:%@",error.description);
    }];
}

// 我的借出
- (void)hope_listMyBorrowOutForApp:(int)curPage andRPP:(int)rpp andType:(NSString *)type andCB:(void (^)(NSDictionary *rqOutput))CB{
    NSDictionary *params = @{@"curPage":[NSString stringWithFormat:@"%d",curPage],
                             @"rPP":[NSString stringWithFormat:@"%d",rpp],
                             @"status":type
                             };
    NSString *requestStr = [NSString stringWithFormat:@"%@/hope/selectmyborrowoutforapp.json",SERVICE_ADRESS];
    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    manager.responseSerializer = [[AFHTTPResponseSerializer alloc] init];
    [manager GET:requestStr parameters:params success:^(AFHTTPRequestOperation * _Nonnull operation, id  _Nonnull responseObject) {
        NSDictionary *jsonObject = [NSJSONSerialization JSONObjectWithData:responseObject options:0 error:nil];
        CB(jsonObject);
        ITLogSP(@"%@",jsonObject);
    } failure:^(AFHTTPRequestOperation * _Nullable operation, NSError * _Nonnull error) {
        ITLogSP(@"error:%@",error.description);
    }];
}

- (void)user_getToInComeForAppCB:(void (^)(id output))CB{
    NSString *requestStr = [NSString stringWithFormat:@"%@/user/gettoincomeforapp.json",SERVICE_ADRESS];
    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    manager.responseSerializer = [[AFHTTPResponseSerializer alloc] init];
    [manager GET:requestStr parameters:nil success:^(AFHTTPRequestOperation * _Nonnull operation, id  _Nonnull responseObject) {
        NSDictionary *jsonObject = [NSJSONSerialization JSONObjectWithData:responseObject options:0 error:nil];
        CB(jsonObject);
    } failure:^(AFHTTPRequestOperation * _Nullable operation, NSError * _Nonnull error) {
        ITLogSP(@"error:%@",error.description);
    }];

}
/**
 *  获取我的余额
 */
- (void)user_getAccountAndCB:(void(^)(id output))CB{
    
    NSString *requestStr = [NSString stringWithFormat:@"%@/user/getaccount.json",SERVICE_ADRESS];
    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    manager.responseSerializer = [[AFHTTPResponseSerializer alloc] init];
    [manager GET:requestStr parameters:nil success:^(AFHTTPRequestOperation * _Nonnull operation, id  _Nonnull responseObject) {
        NSDictionary *jsonObject = [NSJSONSerialization JSONObjectWithData:responseObject options:0 error:nil];
        CB(jsonObject);
    } failure:^(AFHTTPRequestOperation * _Nullable operation, NSError * _Nonnull error) {
        ITLogSP(@"error:%@",error.description);
    }];
}
/**
 *  充值
 */
- (void)user_chargeMoneyWithMoney:(NSString *)money andCB:(void (^)(id output))CB{

    NSString *requestStr = [NSString stringWithFormat:@"%@/user/chargemoney.json",SERVICE_ADRESS];
    NSDictionary *params = @{@"amount":money,
                             @"channel":@"1",
                             @"flag":@"1"};
    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    manager.responseSerializer = [[AFHTTPResponseSerializer alloc] init];
    [manager GET:requestStr parameters:params success:^(AFHTTPRequestOperation * _Nonnull operation, id  _Nonnull responseObject) {
        NSDictionary *jsonObject = [NSJSONSerialization JSONObjectWithData:responseObject options:0 error:nil];
        CB(jsonObject);
    } failure:^(AFHTTPRequestOperation * _Nullable operation, NSError * _Nonnull error) {
        ITLogSP(@"error:%@",error.description);
    }];

}

/**
 *  提现
 */
- (void)user_withdrawMoneyWithMoney:(NSString *)money andCB:(void(^)(id output))CB{
    NSString *requestStr = [NSString stringWithFormat:@"%@/user/withdrawmoney.json",SERVICE_ADRESS];
    NSDictionary *params = @{@"money":money,
                             @"channel":@"1",
                             @"flag":@"1"};
    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    manager.responseSerializer = [[AFHTTPResponseSerializer alloc] init];
    [manager GET:requestStr parameters:params success:^(AFHTTPRequestOperation * _Nonnull operation, id  _Nonnull responseObject) {
        NSDictionary *jsonObject = [NSJSONSerialization JSONObjectWithData:responseObject options:0 error:nil];
        CB(jsonObject);
    } failure:^(AFHTTPRequestOperation * _Nullable operation, NSError * _Nonnull error) {
        ITLogSP(@"error:%@",error.description);
    }];

}


/**
 *  获取总资产
 */
- (void)fetchMyAllTotalInfoAndCB:(void(^)(id output))CB{
    NSString *requestStr = [NSString stringWithFormat:@"%@/user/getamountdetailforapp.json",SERVICE_ADRESS];
    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    manager.responseSerializer = [[AFHTTPResponseSerializer alloc] init];
    [manager GET:requestStr parameters:nil success:^(AFHTTPRequestOperation * _Nonnull operation, id  _Nonnull responseObject) {
        NSDictionary *jsonObject = [NSJSONSerialization JSONObjectWithData:operation.responseData options:0 error:nil];
        CB(jsonObject);
    } failure:^(AFHTTPRequestOperation * _Nullable operation, NSError * _Nonnull error) {
        ITLogSP(@"error:%@",error.description);
    }];
}

/**
 *  个人中心接口
 */
- (void)fetchMyUserInfoAndCB:(void(^)(id output))CB{
    NSString *requestStr = [NSString stringWithFormat:@"%@/user/getusermessageinfo4app.json",SERVICE_ADRESS];
    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    manager.responseSerializer = [[AFHTTPResponseSerializer alloc] init];
    [manager GET:requestStr parameters:nil success:^(AFHTTPRequestOperation * _Nonnull operation, id  _Nonnull responseObject) {
        NSDictionary *jsonObject = [NSJSONSerialization JSONObjectWithData:operation.responseData options:0 error:nil];
        CB(jsonObject);
    } failure:^(AFHTTPRequestOperation * _Nullable operation, NSError * _Nonnull error) {
        ITLogSP(@"error:%@",error.description);
    }];
}

/**
 *  修改昵称
 */
- (void)editNickName:(NSString *)nickName andCB:(void(^)(id output))CB{

    
    
}
@end
